/*
 * Copyright 2009 SHOP.COM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.shop.opensocial.mediated.shindig.factories;

import org.apache.shindig.social.core.model.ActivityImpl;
import com.shop.opensocial.mediated.types.ActivityMediator;
import com.shop.opensocial.mediated.types.MediaItemMediator;
import org.apache.shindig.social.opensocial.model.Activity;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Factory for converting between Mediator type and Shindig type
 *
 * @author Jordan Zimmerman
 */
public class ActivityMediatorFactory extends GenericMediatorFactory<Activity, ActivityMediator>
{
	public static final GenericMediatorFactoryBase<Activity, ActivityMediator>		i = new ActivityMediatorFactory();

	@Override
	protected Activity internalMake(ActivityMediator c)
	{
		Activity		a = new ActivityImpl();
		a.setAppId(c.getAppId());
		a.setBody(c.getBody());
		a.setBodyId(c.getBodyId());
		a.setExternalId(c.getExternalId());
		a.setId(c.getId());
		a.setMediaItems(MediaItemMediatorFactory.i.makeList(c.getMediaItems()));
		a.setPostedTime(c.getPostedTime());
		a.setPriority(c.getPriority());
		a.setStreamFaviconUrl(c.getStreamFaviconUrl());
		a.setStreamSourceUrl(c.getStreamSourceUrl());
		a.setStreamTitle(c.getStreamTitle());
		a.setStreamUrl(c.getStreamUrl());
		a.setTemplateParams(c.getTemplateParams());
		a.setTitle(c.getTitle());
		a.setTitleId(c.getTitleId());
		a.setUpdated(c.getUpdated());
		a.setUrl(c.getUrl());
		a.setUserId(c.getUserId());

		return a;
	}

	@Override
	protected ActivityMediator internalUnmake(final Activity c)
	{
		return new ActivityMediator()
		{
			@Override
			public String getAppId()
			{
				return c.getAppId();
			}

			@Override
			public String getBody()
			{
				return c.getBody();
			}

			@Override
			public String getBodyId()
			{
				return c.getBodyId();
			}

			@Override
			public String getExternalId()
			{
				return c.getExternalId();
			}

			@Override
			public String getId()
			{
				return c.getId();
			}

			@Override
			public Date getUpdated()
			{
				return c.getUpdated();
			}

			@Override
			public List<MediaItemMediator> getMediaItems()
			{
				return MediaItemMediatorFactory.i.unmakeList(c.getMediaItems());
			}

			@Override
			public Long getPostedTime()
			{
				return c.getPostedTime();
			}

			@Override
			public Float getPriority()
			{
				return c.getPriority();
			}

			@Override
			public String getStreamFaviconUrl()
			{
				return c.getStreamFaviconUrl();
			}

			@Override
			public String getStreamSourceUrl()
			{
				return c.getStreamSourceUrl();
			}

			@Override
			public String getStreamTitle()
			{
				return c.getStreamTitle();
			}

			@Override
			public String getStreamUrl()
			{
				return c.getStreamUrl();
			}

			@Override
			public Map<String, String> getTemplateParams()
			{
				return c.getTemplateParams();
			}

			@Override
			public String getTitle()
			{
				return c.getTitle();
			}

			@Override
			public String getTitleId()
			{
				return c.getTitleId();
			}

			@Override
			public String getUrl()
			{
				return c.getUrl();
			}

			@Override
			public String getUserId()
			{
				return c.getUserId();
			}
		};
	}

	private ActivityMediatorFactory()
	{
	}
}
